<style lang=sass>
@import "../../assets/sass/radio/radio.scss";
</style>

<template>
<label class="vue-radio">
	<span class="vue-radio-inner">
		<input :name="name" :value="value" class="vue-radio-input" type="radio" :disabled="disabled" :checked="checked" @change="onChanged"/>
		<i class="vue-radio-icon"></i>
	</span>
	<span class="vue-radio-text">{{text}}</span>
</label>
</template>

<script>
export default{
	props:{
		name:String,
		checked:String,
		disabled:String,
		text:String,
		value:String,
		option:Object//继承父组件传递的options参数
	},
	data(){
		return{
			
		}
	},
	created(){
		var _option=this.option;
		if(_option!=undefined){
			this.name=_option.name;
			this.checked=_option.checked=="checked"?"checked":null;
			this.disabled=_option.disabled=="disabled"?"disabled":null;
			this.text=_option.text!=undefined?_option.text:"";
			this.value=_option.value!=undefined?_option.value:"";
		}
	},
	methods:{
		onChanged(){
			this.checked="checked";
			this.$emit("changed",{
				value:this.value,
				text:this.text,
				checked:this.checked
			});
		}
	}
}

</script>